home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ für Kids
/
C++ for kids.iso
/
Buch
/
Monster2.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-16
|
3KB
|
89 lines
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Monster2.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
class TMonster
{
private:
String Name;
String Wesen;
public:
void Erscheinen(void);
virtual String Typ (void) {return "Monster";};
TMonster (String N, String W);
};
class TGMonster : public TMonster
{
public:
virtual String Typ (void) {return "GeistesMonster";};
TGMonster (String N, String W);
};
class TSMonster : public TMonster
{
public:
virtual String Typ (void) {return "SeelenMonster";};
TSMonster (String N, String W);
};
//---------------------------------------------------------------------------
TMonster *Frank; // Ganz der Vater?
TGMonster *Albert; // Etwa Einstein?
TSMonster *Sigmund; // Doch nicht Freud?
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
TMonster::TMonster (String N, String W)
{
Name = N; Wesen = W;
}
//---------------------------------------------------------------------------
TGMonster::TGMonster (String N, String W) : TMonster (N, W)
{
}
//---------------------------------------------------------------------------
TSMonster::TSMonster (String N, String W) : TMonster (N, W)
{
}
//---------------------------------------------------------------------------
void TMonster::Erscheinen (void)
{
Form1->Label1->Caption = "Name: " + Name;
Form1->Label2->Caption = "Wesen: " + Wesen;
Form1->Label3->Caption = "Typ: " + Typ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Frank = new TMonster ("Frankie", "ungew÷hnlich");
Albert = new TGMonster ("Berti", "nachdenklich");
Sigmund = new TSMonster ("Sigi", "mitfⁿhlend");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Frank->Erscheinen ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Albert->Erscheinen ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Sigmund->Erscheinen ();
}
//---------------------------------------------------------------------------